<template>
<!-- 视频数据 -->
  <el-card shadow="never" class="aui-card--fill">
    <div class="mod-IsFile__isfile">
      <el-form
        :inline="true"
        :model="dataForm"
        @keyup.enter.native="getDataList()"
      >
        <el-form-item>
          <SelectComponent
            dictType="source_file"
            v-model="dataForm.source"
            placeholder="来源模块"
          >
          </SelectComponent>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="dataForm.name"
            placeholder="文件名称"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-date-picker
            value-format="yyyy-MM-dd HH:mm:ss"
            v-model="dataForm.createDatestart"
            type="datetime"
            placeholder="上传时间(起始时间)"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-date-picker
            value-format="yyyy-MM-dd HH:mm:ss"
            v-model="dataForm.createDateEnd"
            type="datetime"
            placeholder="上传时间 (截止时间)"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <SelectComponent
            dictType="file_type"
            v-model="dataForm.fileType"
            placeholder="文件类型"
          >
          </SelectComponent>
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">{{ $t("query") }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="exportHandle()">{{
            $t("export")
          }}</el-button>
        </el-form-item>
        <el-form-item>
          <el-button
            v-if="$hasPermission('IsFile:isfile:save')"
            type="primary"
            @click="addOrUpdateHandle()"
            >{{ $t("add") }}</el-button
          >
        </el-form-item>
        <el-form-item>
          <el-button
            v-if="$hasPermission('IsFile:isfile:delete')"
            type="danger"
            @click="deleteHandle()"
            >{{ $t("deleteBatch") }}</el-button
          >
        </el-form-item>
      </el-form>
      <el-table
        v-loading="dataListLoading"
        :data="dataList"
        border
        @selection-change="dataListSelectionChangeHandle"
        style="width: 100%"
      >
        <el-table-column
          type="selection"
          header-align="center"
          align="center"
          width="50"
        ></el-table-column>
        <!-- <el-table-column prop="id" label="ID" header-align="center" align="center"></el-table-column> -->
        <!-- <el-table-column
          prop="sourceId"
          label="来源ID"
          header-align="center"
          align="center"
        ></el-table-column> -->
        <el-table-column
          prop="path"
          label="文件路径"
          header-align="center"
          align="center"
        >
          <template slot-scope="scope">
            <a :href="scope.row.path"  target="_blank">{{ scope.row.path }}</a>
          </template>
        </el-table-column>
        <el-table-column
          prop="name"
          label="文件名称"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="size"
          label="文件大小"
          header-align="center"
          align="center"
        ></el-table-column>
        <el-table-column
          prop="sourceName"
          label="来源模块"
          header-align="center"
          align="center"
        ></el-table-column>
        <!-- <el-table-column
          prop="sort"
          label="排序"
          header-align="center"
          align="center"
        ></el-table-column> -->
        <el-table-column
          prop="fileTypeName"
          label="文件类型"
          header-align="center"
          align="center"
          ></el-table-column>
          <el-table-column prop="createDate" label="上传时间" header-align="center" align="center"></el-table-column>
        <!-- <el-table-column prop="type" label="文件类型(业务使用)" header-align="center" align="center"></el-table-column> -->
        <!-- <el-table-column prop="status" label="'状态  0：停用    1：正常'" header-align="center" align="center"></el-table-column>
        <el-table-column prop="remark" label="备注" header-align="center" align="center"></el-table-column>
        <el-table-column prop="delFlag" label="'删除标识  0：未删除    1：删除'" header-align="center" align="center"></el-table-column>
        <el-table-column prop="creator" label="创建者" header-align="center" align="center"></el-table-column>
        <el-table-column prop="updater" label="更新者" header-align="center" align="center"></el-table-column>
        <el-table-column prop="updateDate" label="更新时间" header-align="center" align="center"></el-table-column> -->
        <el-table-column
          :label="$t('handle')"
          fixed="right"
          header-align="center"
          align="center"
          width="150"
        >
          <template slot-scope="scope">
            <el-button
              v-if="$hasPermission('IsFile:isfile:update')"
              type="text"
              size="small"
              @click="addOrUpdateHandle(scope.row.id)"
              >{{ $t("update") }}</el-button
            >
            <el-button type="text" size="small" @click="viewHandle(scope.row)"
              >查看</el-button
            >
            <el-button
              v-if="$hasPermission('IsFile:isfile:delete')"
              type="text"
              size="small"
              @click="deleteHandle(scope.row.id)"
              >{{ $t("delete") }}</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        :current-page="page"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="limit"
        :total="total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="pageSizeChangeHandle"
        @current-change="pageCurrentChangeHandle"
      >
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update
        v-if="addOrUpdateVisible"
        ref="addOrUpdate"
        @refreshDataList="getDataList"
        :disabled="disabled"
        @changeDisabled="disabled = false"
      ></add-or-update>
    </div>
  </el-card>
</template>

<script>
import mixinViewModule from "@/mixins/view-module";
import AddOrUpdate from "./isfile-add-or-update";
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      disabled: false,
      mixinViewModuleOptions: {
        getDataListURL: "/sys/isfile/page",
        getDataListIsPage: true,
        exportURL: "/sys/isfile/export",
        deleteURL: "/sys/isfile",
        deleteIsBatch: true,
      },
      dataForm: {},
    };
  },
  watch: {},
  components: {
    AddOrUpdate,
  },
  methods: {
    queding(scoped) {
    },
    viewHandle(row) {
      this.addOrUpdateVisible = true;
      this.disabled = true;
      this.$nextTick(() => {
        this.$refs.addOrUpdate.visible = true;
        // this.$refs.addOrUpdate.dataForm = row;

        this.$refs.addOrUpdate.dataForm.id = row.id;
        this.$refs.addOrUpdate.dataForm.details=true;
        this.$refs.addOrUpdate.init();
      });
    },
  },
};
</script>
